package blackhouse.advanced;

import java.io.IOException;

public class ReadLine {
	public static void main(String[] args) throws IOException {
		byte[] buf = new byte[1024];
		String strInfo = null;
		int pos = 0;
		int ch = 0;
		System.out.println("please enter info:");
		while (true) {
			ch = System.in.read();
			switch (ch) {
			case '\r':
				break;
			case '\n':
				strInfo = new String(buf, 0, pos);
				if (strInfo.equals("bye")) {
					System.out.println("Exit");
					return;
				} else {
					System.out.println(strInfo);
					pos = 0;
					break;
				}
			default:
				buf[pos++] = (byte) ch;
			}
		}
	}

}
